PATHMac OS 8 and 9 Developer Documentation > Interapplication Communication > AppleScript for Scripters >

AppleScript Language Guide

   

Close

Close is an application command that requests the closing of one or more objects, usually application windows or documents.

SYNTAX
close referenceToObject [ saving in referenceToFile ] [ saving saveOption ]
PARAMETERS
referenceToObject
A reference to the object or objects to close, usually application windows or documents. Class: Reference
referenceToFile
A reference of the form file nameString or alias nameString (see "Notes" below). Class: Reference Default value: The file in which the object was last saved. If the object hasn't been saved before, the application follows its normal procedure when first saving a new file, which is typically to ask whether to save the document and, if saving, to let the user specify a name and destination for the file.
saveOption
A parameter that specifies whether to save an object that has been modified before closing it. The constant yes specifies that the object should be saved. The constant no specifies that the object should not be saved. The constant ask specifies that the user must be asked whether or not to save the object. See "Notes" below for more information. Class: Constant Default value: The default value is ask , unless you specify a file in which to save the object, in which case the default value is yes .
RESULT

None

EXAMPLES
tell application "AppleWorks"
    close front window saving in file "Hard Disk:Documents:Report"¬
        saving yes
end tell
tell application "Finder"
    close front window
end tell
NOTES

To specify the name ( nameString ) of a file in which to save the object, use a string of the form " Disk : Folder1 : Folder2 :...: Filename " ; for details, see References to Files. You can also specify a string with only a filename (" Filename "). In this case, the application attempts to find the file in the current directory. If it can't find the specified file, the application creates a file with the specified name in the current directory or, if the name includes a path, then in the directory specified by the path. (The current directory is typically the directory where the application was launched, the directory where the application last opened or saved a previous document, or another directory specified by the application. The current directory may be affected by settings in the General Controls control panel.)

The Close command will typically only save a file if it is "dirty" (has been modified since it was last saved). When the save option is ask , the Close command asks, for each modified document, whether to save the document. Depending on how an the application implements the Close command, the command may save over an existing file with the same name as the specified file without asking.


© 1999 Apple Computer, Inc. – (Last Updated 21 May 99)